package cn.com.callback


import cn.com.elite.EliteBean
import cn.com.kh.KHDBConfig;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import cn.com.elite.Util;
import net.sf.json.JSONObject;
import cn.com.kh.KHUtil;

/**
 *
 * @author xrm
 * @use 获取业务信息
 *
 *
 */
public class GetCarList implements ServiceBackInvoke {
    private static final Log log = LogFactory.getLog(GetCarList.class);
    private String charset = "utf-8"; //设置字符集
    private int timeout = 10000; //设置请求超时时间
    private int enableSSLflag = 1;

    public String doCallBack(EliteBean eliteBean, HttpServletRequest request, HttpServletResponse response) {
        response.setCharacterEncoding("UTF-8");
        response.setContentType("application/json");
        JSONObject result = new JSONObject();
        def smap, oJson, SaveResult;
        try {
            //获取客户端传参
            def r_customerid = Util.filterForObject(request.getParameter("customerid")); //客户编号
            def r_vehicularNo = Util.filterForObject(request.getParameter("vehicularNo")); //车牌
            def r_customername = Util.filterForObject(request.getParameter("customername")); //档主姓名
            def r_shopid = Util.filterForObject(request.getParameter("shopid")); //档位号
            def r_employee = Util.filterForObject(request.getParameter("employee")); //车主姓名
            log.debug("NGS传参:" + r_customerid);
            //传参处理

            //列表接口调用
            if (r_customerid.equals("") && r_vehicularNo.equals("") && r_customername.equals("") && r_shopid.equals("") && r_employee.equals("")) {
                result.put("status", "-1");
                result.put("message", "未传递参数！");
                return result
            }
            Map<String, String> map = new HashMap<String, String>();
            map.put("customerid", r_customerid);
            map.put("vehicularNo", r_vehicularNo);
            map.put("customername", r_customername);
            map.put("shopid", r_shopid);
            map.put("employee", r_employee);
            map.put("key", "ca3c64a49d1f11ecbed6d703198897725e7aba55");
            def ASCIIMD5 = KHUtil.ASCIIORDER(map);
            log.debug("接口返回:" + ASCIIMD5);
            //调用接口方法
            oJson = CarHttpPort(eliteBean, ASCIIMD5);

            log.debug("接口返回:" + oJson);
            return oJson;


        } catch (Exception e) {
            log.error("errormsg:", e)
            result.put("status", "-99");
            result.put("message", "程序异常！");
            return result;
        }
    }


/**
 *
 * @use 业务历史接口调用
 * @param eliteBean
 * @param Custname ,Mobile,Idno,Custnameid* @return
 */
    private String CarHttpPort(EliteBean eliteBean, ASCIIMD5) {
        JSONObject result = new JSONObject();
        def smap, mopsmap, chatqueue, customer_guid, url = "";
        try {
            //获取接口地址
            url = KHDBConfig.getAPIURL(eliteBean, "getTcmonthiccardPnoList");
            def postmap = Util.doHttpPost(url, ASCIIMD5.toString(), charset, timeout, 0);
            log.debug("接口返回:" + postmap);
            return postmap;
        } catch (Exception e) {
            log.error("errormsg:", e)
            result.put("status", "-99");
            result.put("message", "程序异常");
            return result;
        }
    }


}








